import {
  _decorator,
  Component,
  instantiate,
  log,
  Node,
  Prefab,
  SpriteFrame,
} from "cc";
const { ccclass, property } = _decorator;
import { itemLabel } from "./itemLabel";
@ccclass("Item")
export class Item {
  @property
  itemName = "";
}

@ccclass
export class ItemList extends Component {
  @property([Item])
  items: Item[] = [];
  @property(Prefab)
  itemPrefab: Prefab | null = null;

  onLoad() {
    for (let i = 0; i < this.items.length; ++i) {
      const item = instantiate(this.itemPrefab);
      const data = this.items[i];
      this.node.addChild(item);
      log(data.itemName);
    //   (item.getComponent("itemLabel") as itemLabel).init(data);
    }
  }
}
